<?php

namespace App\Services\WeChat;

use App\Services\WeChat\Templates\AppointFailTemplate;
use App\Services\WeChat\Templates\AppointSuccessTemplate;
use App\Services\WeChat\Templates\EduTemplate;
use App\Services\WeChat\Templates\MedicalReminderTemplate;
use InvalidArgumentException;

class TemplateFactory
{
    protected $dispatcher;

    public function __construct(MessageDispatcher $dispatcher)
    {
        $this->dispatcher = $dispatcher;
    }

    public function create(string $type)
    {
        switch ($type) {
            case 'medical_reminder':
                return new MedicalReminderTemplate($this->dispatcher);
            case 'appoint_success':
                return new AppointSuccessTemplate($this->dispatcher);
            case 'appoint_fail':
                return new AppointFailTemplate($this->dispatcher);
            case 'edu':
                return new EduTemplate($this->dispatcher);
            default:
                throw new InvalidArgumentException("Unsupported template type: {$type}");
        }
    }
}
